package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysWechatMapper;
import com.ruoyi.system.domain.SysWechat;
import com.ruoyi.system.service.ISysWechatService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 微信信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-08-08
 */
@Service
public class SysWechatServiceImpl implements ISysWechatService
{
    @Autowired
    private SysWechatMapper sysWechatMapper;

    /**
     * 查询微信信息
     *
     * @param id 微信信息主键
     * @return 微信信息
     */
    @Override
    public SysWechat selectSysWechatById(Long id)
    {
        return sysWechatMapper.selectSysWechatById(id);
    }

    /**
     * 查询微信信息列表
     *
     * @param sysWechat 微信信息
     * @return 微信信息
     */
    @Override
    public List<SysWechat> selectSysWechatList(SysWechat sysWechat)
    {
        return sysWechatMapper.selectSysWechatList(sysWechat);
    }

    /**
     * 新增微信信息
     *
     * @param sysWechat 微信信息
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertSysWechat(SysWechat sysWechat)
    {
        String serverAddress = RuoYiConfig.getServerAddress();
        sysWechat.setCreateTime(DateUtils.getNowDate());
        sysWechat.setUserId(SecurityUtils.getUserId());
        int i = sysWechatMapper.insertSysWechat(sysWechat);
        sysWechat.setRemark(serverAddress+ "?id=" + sysWechat.getId());
        return sysWechatMapper.updateSysWechat(sysWechat);
    }

    /**
     * 修改微信信息
     *
     * @param sysWechat 微信信息
     * @return 结果
     */
    @Override
    public int updateSysWechat(SysWechat sysWechat)
    {
        sysWechat.setUpdateTime(DateUtils.getNowDate());
        return sysWechatMapper.updateSysWechat(sysWechat);
    }

    /**
     * 批量删除微信信息
     *
     * @param ids 需要删除的微信信息主键
     * @return 结果
     */
    @Override
    public int deleteSysWechatByIds(Long[] ids)
    {
        return sysWechatMapper.deleteSysWechatByIds(ids);
    }

    /**
     * 删除微信信息信息
     *
     * @param id 微信信息主键
     * @return 结果
     */
    @Override
    public int deleteSysWechatById(Long id)
    {
        return sysWechatMapper.deleteSysWechatById(id);
    }
}
